package org.zfes.snowier.cloud.zbss.cms.router.service.comment;

import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.cms.comment.model.CmsComment;
import org.zfes.snowier.cloud.zbss.cms.comment.service.ICmsCommentService;
@Controller("org.zfes.snowier.cloud.zbss.cms.router.service.comment.CmsCommentController") 
@RequestMapping("/cms/service/comment/cmsComment")
public class CmsCommentController extends BaseController {

	
	@Autowired
	private ICmsCommentService cmsCommentService;
	
	@RequiresPermissions(value="cmsComment:loadCmsCommentDataSet",desc="评论列表")
    @RequestMapping(value="/loadCmsCommentDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsCommentDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  cmsCommentService.loadCmsCommentDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	@RequiresPermissions(value="cmsComment:createCmsComment",desc="评论添加")
    @RequestMapping(value="/createCmsComment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createCmsComment(CmsComment cmsComment){
		cmsCommentService.createCmsComment(cmsComment);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsComment:loadCmsComment",desc="评论加载")
    @RequestMapping(value="/loadCmsComment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsComment(Long id){
		Optional<CmsComment> ops = cmsCommentService.loadCmsCommentById(id);
		return ajaxQuery("cmsComment",ops);
    }
	
	@RequiresPermissions(value="cmsComment:updateCmsComment",desc="评论更新")
    @RequestMapping(value="/updateCmsComment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateCmsComment(CmsComment cmsComment){
		cmsCommentService.updateCmsComment(cmsComment);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsComment:deletCmsComment",desc="评论删除")
    @RequestMapping(value="/deleteCmsComment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteCmsComment(Long id){
		cmsCommentService.deleteCmsComment(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}